<!-- components/ChapterList.vue -->
<template>
  <div class="chapter-list">
    <div v-for="section in sections" :key="section.sectionId" class="chapter-item">
      <div class="chapter-title">
        <span>{{ section.sectionName }}</span>
        <span v-if="section.canTry === '1'" class="try-tag">试看</span>
      </div>
      <div v-if="section.subSections" class="sub-chapters">
        <chapter-list :sections="section.subSections" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ChapterList',
  props: {
    sections: {
      type: Array,
      default: () => []
    }
  }
}
</script>

<style lang="scss" scoped>
.chapter-item {
  margin: 10px 0;
  padding-left: 20px;
}

.chapter-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.try-tag {
  color: #1890ff;
  border: 1px solid #1890ff;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 12px;
}

.sub-chapters {
  margin-left: 20px;
}
</style>